//package com.example.demo.command;
//
//import java.util.HashMap;
//import java.util.Map;
//
//import org.flowable.engine.HistoryService;
//import org.flowable.engine.ProcessEngine;
//import org.flowable.engine.RepositoryService;
//import org.flowable.engine.RuntimeService;
//import org.flowable.engine.TaskService;
//import org.flowable.engine.repository.Deployment;
//import org.flowable.engine.repository.ProcessDefinition;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.CommandLineRunner;
//import org.springframework.core.annotation.Order;
//import org.springframework.stereotype.Component;
//
//import com.example.demo.service.FlowTaskService;
//
//@Component
//@Order(value=100)
//public class RunTask implements CommandLineRunner {
//	@Autowired
//	private FlowTaskService flowTaskService;
//	
//	@Autowired
//	private RuntimeService runtimeService;
//	@Autowired
//	private TaskService taskService;
//	@Autowired
//	private HistoryService historyService;
//	@Autowired
//	private RepositoryService repositoryService;
//	@Autowired
//	private ProcessEngine processEngine;
//	
//	private String processKey = "leave";
//	private String businessKey = "123546879";
//	
//	
//
//	@Override
//	public void run(String... args) throws Exception {
//	}
//	
//	
//	
//	public void deploy() {
//		Deployment deployment = repositoryService.createDeployment().key("leave").name("leave").addClasspathResource("leave.bpmn20.xml").deploy();
//		System.out.println("deployId: "+deployment.getId());
//		
//		ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
//				  .deploymentId(deployment.getId())
//				  .singleResult();
//				System.out.println("Found process definition : " + processDefinition.getName());
//				System.out.println("Found process definition : " + processDefinition.getKey());
//				
//				
//		Deployment d = repositoryService.createDeploymentQuery().processDefinitionKey(processKey).singleResult();
//		System.out.println("Found process definition : " + d.getName());
//		System.out.println("Found process definition : " + d.getKey());
//	}
//	
//	public void start() {
//		Map<String, Object> map = getMap();
//		
//		String processInstanceId =  flowTaskService.start(processKey, businessKey, map);
//		System.out.println("processInstanceId:  "+processInstanceId);
//		//e2fa1cd9-7858-11ec-a1aa-2cf05d15c480
//		
//	}
//	
//	public void claim() {
//		flowTaskService.claim("d5c55915-785b-11ec-bd25-2cf05d15c480", "admin");
//	}
//	
//	public void complete() {
//		Map<String, Object> map = getMap();
//		flowTaskService.complete("d267977c-7933-11ec-9b75-2cf05d15c480", map);
//	}
//	
//	public void startAndComplete() {
//		Map<String, Object> map = getMap();
//		flowTaskService.startAndComplete(processKey, businessKey, map);
//	}
//	
//	public void backToStep() {
//		String currTaskId = "a00dd85e-7927-11ec-af5d-2cf05d15c480";
//		String targetTaskId = "072c43d0-78c3-11ec-be41-2cf05d15c480";
//		flowTaskService.backToStep(currTaskId, targetTaskId);
//		taskService.addComment(currTaskId, processKey, "butongyi,bohuiyijian");
//	}
//	
//	public void stop() {
//		flowTaskService.stop("494322c4-7900-11ec-8f97-2cf05d15c480", "ddd");
//	}
//	
//	
//	
//	private Map<String, Object> getMap(){
//		Map<String, Object> map = new HashMap<>();
//		map.put("initiator", "jack");
//		map.put("leaveDays", "6");
//		return map;
//	}
//
//}
